package com.koicarp.university.graduate.web.controller.information;

import com.koicarp.university.graduate.service.entity.FileInfo;
import com.koicarp.university.graduate.service.qiniuyun.FileServiceImpl;
import com.koicarp.university.graduate.service.service.graduateInfoManage.IFileInfoService;
import com.koicarp.university.graudate.common.constant.BaseConstant;
import com.koicarp.university.graudate.common.utils.UniversityResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;


/**
 *
 *
 * @author liutao
 * @since 2020-09-03 19:53:50
 */
@RestController
@RequestMapping("file")
@Slf4j
@RequiredArgsConstructor
public class FileInfoController {

    private final FileServiceImpl fileService;

    @PostMapping("imageUpload")
    @ApiOperation(value = "图片文件上传(单个)" ,notes = "图片文件上传(单个")
    public UniversityResponse saveAcademyInfo(@RequestParam(value = "file", required = false)MultipartFile multipartFile){
        UniversityResponse response=null;
        try{
            response = fileService.imageLoad(multipartFile);
        }catch (Exception e){
            log.error("增加失败",e);
            response = new UniversityResponse();
            response.code(BaseConstant.RESPONSE_CODE_FAILED_500);
            response.message(BaseConstant.RESPONSE_MESSAGE_OPR_FAILED);
        }
        return response;
    }


}